import CardBox from "../components/common/CardBox.vue";
import KbSelect from "../components/common/KbSelect.vue";
import request from '@/utils/request'
import IbpsData from '../data/ibps'
export default {
  components: {
    CardBox,
    KbSelect,
  },
  data() {
    return {
      loadingBg: `rgba(0, 0, 0, 0.8)`,
      loadingTxt: `数据加载中`
    }
  },
  methods: { 
    async queryData(code) {
      const res = await request({
        url: '/ibps/business/v3/data/template/queryDataTable',
        data: IbpsData[code].requestData,
        method: 'post'
      })
      return res.data
    },
    formatNumberWithCommas(num) {
      // 将传入的参数转换为数字类型，如果无法转换则返回原参数
      let number = typeof num === "string"? parseFloat(num) : num;
      if (isNaN(number)) {
          return num;
      }
      return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
    },
    dateFormat(fmt, d) {
      const date = new Date(d);
      const opt = {
        "y+": date.getFullYear().toString(), // 年
        "m+": (date.getMonth() + 1).toString(), // 月
        "d+": date.getDate().toString(), // 日
        "H+": date.getHours().toString(), // 时
        "M+": date.getMinutes().toString(), // 分
        "S+": date.getSeconds().toString(), // 秒
        // 有其他格式化字符需求可以继续添加，必须转化成字符串
      };
      for (let k in opt) {
        let ret = new RegExp("(" + k + ")").exec(fmt);
        if (ret) {
          fmt = fmt.replace(
            ret[1],
            ret[1].length == 1 ? opt[k] : opt[k].padStart(ret[1].length, "0")
          );
        }
      }
      return fmt;
    },
  },
};
